//
//  Header.h
//  Mahjong
//
//  Created by KING on 16/8/30.
//  Copyright © 2016年 Elliot. All rights reserved.
//

#ifndef Header_h
#define Header_h
#import "UIView+SDAutoLayout.h"
#import "AFNetworking.h"
#import "AppTools.h"
#import "UIImageView+WebCache.h"
#import <MJRefresh.h>
//#import <SDWebImage/SDImageCache.h>
//#import "SDImageCache.h"

//获取屏幕宽度、高度
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 // 当前Xcode支持iOS8及以上
#define SCREEN_WIDTH ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]?[UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale:[UIScreen mainScreen].bounds.size.width)
#define SCREENH_HEIGHT ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]?[UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale:[UIScreen mainScreen].bounds.size.height)
#define SCREEN_SIZE ([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)]?CGSizeMake([UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale,[UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale):[UIScreen mainScreen].bounds.size)
#else
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREENH_HEIGHT [UIScreen mainScreen].bounds.size.height
#define SCREEN_SIZE [UIScreen mainScreen].bounds.size
#endif
//获取通知中心
#define KNotificationCenter [NSNotificationCenter defaultCenter]
//获取UserDefaults
#define KUserDefaults [NSUserDefaults standardUserDefaults]
//设置随机颜色
#define KRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
//设置RGB颜色/设置RGBA颜色
#define KRGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define KRGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
//16进制RGB的颜色转换
#define kUIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// clear背景颜色
#define KClearColor [UIColor clearColor]
//自定义高效率的 NSLog
#ifdef DEBUG
#define KLog(...) NSLog(@"%s 第%d行  %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define KLog(...)
#endif
//弱引用/强引用
#define KWeakSelf(type)  __weak typeof(type) weak##type = type;
#define KStrongSelf(type)  __strong typeof(type) type = weak##type;
//设置 view 圆角和边框
#define KViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]
//由角度转换弧度 由弧度转换角度
#define KDegreesToRadian(x) (M_PI * (x) / 180.0)
#define KRadianToDegrees(radian) (radian*180.0)/(M_PI)
//获取图片资源
#define KGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]
//获取当前语言
#define KCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//判断是否为iPhone
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
//判断是否为iPad
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//判断是否为ipod
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
// 判断是否为 iPhone 5SE
#define iPhone5SE [[UIScreen mainScreen] bounds].size.width == 320.0f && [[UIScreen mainScreen] bounds].size.height == 568.0f
// 判断是否为iPhone 6/6s
#define iPhone6_6s [[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 667.0f
// 判断是否为iPhone 6Plus/6sPlus
#define iPhone6Plus_6sPlus [[UIScreen mainScreen] bounds].size.width == 414.0f && [[UIScreen mainScreen] bounds].size.height == 736.0f
//获取系统版本
#define IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
//判断 iOS 8 或更高的系统版本
#define IOS_VERSION_8_OR_LATER (([[[UIDevice currentDevice] systemVersion] floatValue] >=8.0)? (YES):(NO))
//获取temp
#define KPathTemp NSTemporaryDirectory()
//获取沙盒 Document
#define KPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache
#define KPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
//GCD - 一次性执行
#define KDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//GCD - 在Main线程上运行
#define KDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
//GCD - 开启异步线程
#define KDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
//老版alert弹框
#define SHOW_ALERT(aMessage) UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"友情提示" message:aMessage preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];\
[alert addAction:action];\
[self presentViewController:alert animated:YES completion:nil]
//新版alert弹框
#define KSHOW_ALERT(Title,Message,ActionTitle) UIAlertController *alc = [UIAlertController alertControllerWithTitle:Title message:Message preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *action1 =[UIAlertAction actionWithTitle:ActionTitle style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {}];\
[alc addAction:action1];\
[self presentViewController:alc animated:YES completion:nil]
//登录alert弹框
#define KLogin_ALERT UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"友情提示" message:@"您还没有登录~" preferredStyle:UIAlertControllerStyleAlert];\
UIAlertAction *action1 =[UIAlertAction actionWithTitle:@"再逛逛" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {}];\
UIAlertAction *action2 =[UIAlertAction actionWithTitle:@"去登陆" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {L_RController *l_r = [[L_RController alloc] init];\
[self presentViewController:l_r animated:YES completion:nil];\
}];\
[alert addAction:action1];\
[alert addAction:action2];\
[self presentViewController:alert animated:YES completion:nil]
// URL
#define MAINURL @"http://120.55.70.81:8088/%@"
//获取分类信息
#define FENLEI @"http://120.55.70.81:8088/shop/get_info/status/1/b_class/%@"
//图片接口的URL前缀
#define IMAGEURL @"http://www.hzdajiawang.com/%@"
//获取购物车信息
#define SHOPCAR @"http://120.55.70.81:8088/shop/get_shop_cart"
//获取动态
#define GETDynamic @"http://120.55.70.81:8088/home/get_moments"


#define USERNAME      @"USERNAME_KEY"
#define USERPWD      @"PASSWORD_KEY"




#endif /* Header_h */
